<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../views/common/taglibs.jsp"%>
  <div id="u30" class="ax_default shape">
                <div id="u30_div" class=""></div>
                <!-- Unnamed () -->
                <div id="u31" class="text" style="visibility: visible;">
                  <p><span>
                  	编辑商品
        			</span></p>
                </div>
  </div>
  <div id="u30" class="ax_default shape">
  		
		<a href="javascript:doActionNoCallback('core', '${appServer}/back/item/getItemList.htm', itemListParam);">&lt;返回</a>
		<br/>
  </div>
  <div class="search">
	    <form id="editItemDetailFrm" name="editItemDetailFrm" action="${appServer}/back/item/updateItem.htm" method="post" onsubmit="return false;">
		    <table>
				<c:if test="${msg!=null}">
        		<tr>
			    	<td class="tc">
	        			<h2>${msg}</h2>
	        		</td>
				</tr>
  				</c:if>
  				<c:if test="${errorMsg!=null}">
        		<tr>
			    	<td class="tc">
	        			<h2><font color="#FF0000">${errorMsg}</font></h2>
	        		</td>
				</tr>
  				</c:if>
				<tr>
			      	<td>
			      		描述：&nbsp;&nbsp;
			      		<input type="text" style="width: 280px;" name="itemDesc" value="${item.itemDesc}"/>
			      	</td>
			   </tr>
			   <tr>
					<td style="text-align:left;">添加图片：<input type="file" id="imageUpload" name="file" style="display:-webkit-inline-box;width: 180px;"/>
					&nbsp;&nbsp;&nbsp;<input class="btn_add" value="上传图片" type="button" style="font-size: 9px;" onclick="updataItemImage();"/>
					<input id="picInput" type="hidden" name="pic" value=""/>
					<input id="descPicInput" type="hidden" name="descPic" value=""/>
					</td>
				</tr>
				<tr>
			      	<c:if test="${descPicList!=null}">
				      	<td id="itemImages">
				      		<span style='position: relative;'>
				      			<img src="${item.pic}" alt="商品图片" height="100px" width="auto"/>&nbsp;
				      			<input type='image' src='../../images/main/Delete.png' onclick='deleteImage(this);'>&nbsp;&nbsp;
				      		</span>
				      		<c:forEach items="${descPicList}" var="descPicTemp" varStatus="status">
				      			<span style='position: relative;'>
				      				<img src="${descPicTemp}" alt="商品图片" height="100px" width="auto"/>
				      				<input type='image' src='../../images/main/Delete.png' onclick='deleteImage(this);'>&nbsp;&nbsp;
				      			</span>
				      		</c:forEach>
				      	</td>
			      	</c:if>
			   </tr>
			   <tr>
			      	<td>
			      		类目：&nbsp;&nbsp;
			      		<c:if test="${item.categoryFullTitle!=null}">
			      		${item.categoryFullTitle}
			      		</c:if>
			      	</td>
			   </tr>
			   <tr>
			      	<td>
			      		品牌：&nbsp;&nbsp;
			      		<c:if test="${item.brandTitle!=null}">
			      		${item.brandTitle}
			      		</c:if>
			      	</td>
			   </tr>
			   <tr>
			      	<td>
			      		适用人群：&nbsp;&nbsp;
			      		<select class="userinfo" id="featureSelect" name="feature" style="width: 90px;" onchange="selectFeature(this);">
							<option value=10 <c:choose><c:when test="${0 == item.feature}">selected="selected"</c:when></c:choose>>通用</option>
							<option value=0 <c:choose><c:when test="${0 == item.feature}">selected="selected"</c:when></c:choose>>女</option>
							<option value=1 <c:choose><c:when test="${1 == item.feature}">selected="selected"</c:when></c:choose>>男</option>
						</select>
			      	</td>
			   </tr>
				<tr>
			      	<td>
			      		建议零售价：&nbsp;&nbsp;
			      		<input type="text" style="width: 180px;" name="referencePriceDisplay" value="${item.referencePriceDisplay}"/>
			      	</td>
			   </tr>
				<tr>
			      	<td>
			      		结算价：&nbsp;&nbsp;
			      		<input type="text" style="width: 180px;" name="priceDisplay" value="${item.priceDisplay}"/>
			      	</td>
			   </tr>
				<tr>
			      	<td>
			      		货币单位：&nbsp;&nbsp;
			      		<c:choose> 
  						<c:when test="${'CNY' != item.priceCurno}">   
			      		<select class="userinfo" name="priceCurno" style="width: 90px;">
							<option value="CNY" <c:choose><c:when test="${'CNY' == item.priceCurno}">selected="selected"</c:when></c:choose>>人民币</option>
							<option value="HKD" <c:choose><c:when test="${'HKD' == item.priceCurno}">selected="selected"</c:when></c:choose>>港币</option>
							<option value="EUR" <c:choose><c:when test="${'EUR' == item.priceCurno}">selected="selected"</c:when></c:choose>>欧元</option>
							<option value="USD" <c:choose><c:when test="${'USD' == item.priceCurno}">selected="selected"</c:when></c:choose>>美元</option>
							<option value="GBP" <c:choose><c:when test="${'GBP' == item.priceCurno}">selected="selected"</c:when></c:choose>>英镑</option>
							<option value="TWD" <c:choose><c:when test="${'TWD' == item.priceCurno}">selected="selected"</c:when></c:choose>>台币</option>
							<option value="JPY" <c:choose><c:when test="${'JPY' == item.priceCurno}">selected="selected"</c:when></c:choose>>日元</option>
							<option value="KRW" <c:choose><c:when test="${'KRW' == item.priceCurno}">selected="selected"</c:when></c:choose>>韩国元</option>
						</select>
						</c:when>
						<c:otherwise>   
			      		<select class="userinfo" name="priceCurno" style="width: 90px;">
							<option value="CNY">人民币</option>
							<option value="HKD">港币</option>
							<option value="EUR">欧元</option>
							<option value="USD">美元</option>
							<option value="GBP">英镑</option>
							<option value="TWD">台币</option>
							<option value="JPY">日元</option>
							<option value="KRW">韩国元</option>
						</select>
						</c:otherwise>
						</c:choose>
			      	</td>
			   </tr>
			   <tr>
			      	<td>
			      		原商品编码：&nbsp;&nbsp;
			      		<c:if test="${itemCodeOrigin!=null}">
			      		${itemCodeOrigin}
			      		<input type="hidden" name="itemCodeOrigin" value="${itemCodeOrigin}"/>
			      		</c:if>
			      	</td>
			   </tr>
			   <tr>
			      	<td>
			      		商品编码图：<input type="file" id="itemCodeImageUpload" name="file" style="display:-webkit-inline-box;width: 180px;"/>
				      	&nbsp;&nbsp;&nbsp;<input class="btn_add" value="上传图片" type="button" style="font-size: 9px;" onclick="updataItemCodeImage();"/>
						<c:if test="${item.itemCodePic!=null}">
			      		<input id="itemCodePicInput" type="hidden" name="itemCodePic" value="${item.itemCodePic}"/>
				        </c:if>
				        <c:if test="${item.itemCodePic==null}">
			      		<input id="itemCodePicInput" type="hidden" name="itemCodePic" value=""/>
				        </c:if>
			      	</td>
			   </tr>
				<tr>
			      	<td id="itemCodeImage">
			      		<c:if test="${item.itemCodePic!=null}">
			      		<span style='position: relative;'>
				        <img src="${item.itemCodePic}" alt="商品编码图" height="auto" width="150px"/>
				        <input type='image' src='../../images/main/Delete.png' name='img'  onclick='deleteImage(this);' >&nbsp;&nbsp;
				        </span>
				        </c:if>
			      	</td>
			   </tr>
			    <tr>
			      	<td>
			      		商品编码：&nbsp;&nbsp;
			      		<input type="text" style="width: 180px;" name="itemCode" value="${item.itemCode}"/>
			      		<input type="hidden" name="id" value="${item.id}"/>
			      		<input type="hidden" name="itemDescBack" value="${itemDescBack}"/>
			      		<input type="hidden" name="itemCodeBack" value="${itemCodeBack}"/>
			      		<input type="hidden" name="memberNameBack" value="${memberNameBack}"/>
			      		<input type="hidden" name="itemListPageNum" value="${itemListPageNum}"/>
			      	</td>
			    </tr>
				<tr>
			      	<td height="50">
			      		<hr/>
			      	</td>
			   </tr>
				<tr>
			      	<th style="text-align:left;">
			      		<div id="u33" class="text" style="visibility: visible;">
		                  <p><b>
		                  	标签管理：
		        			</b></p>
		                </div>
			      	</th>
			   </tr>
			    <tr>
			      	<td>
			      		标签：&nbsp;&nbsp;
				      		<input id="tagInput" type="text" style="width: 180px;"/>
				      		&nbsp;&nbsp;&nbsp;<input class="btn_add" value="添加" type="button" style="font-size: 9px;" onclick="addItemTag();"/>
				      		<input class="tagListInput" type="hidden" name="tagListString" value=""/>
			      	</td>
			    </tr>
			    <tr>
			      	<td>
			      		已添加标签：
			      	</td>
			   </tr>
				<tr>
			      	<td id="itemTags" style="text-align:left;">
			      		<c:if test="${itemTagList!=null}">
				      		<c:forEach items="${itemTagList}" var="itemTagTemp" varStatus="status">
				      			<span style='position: relative;'>
				      				<button class="tagListButton" type="button" disabled="disabled">${itemTagTemp.tagTitle}</button>
				      				<input type='image' style="width:15px;height:auto;" src='../../images/main/Delete.png' onclick='deleteTag(this);'>&nbsp;&nbsp;
				      			</span>
				      		</c:forEach>
			      		</c:if>
			      	</td>
			   </tr>
				<tr>
			      	<td height="50">
			      		<hr/>
			      	</td>
			   </tr>
				<tr>
			      	<td>
			      		<div id="u32" class="text" style="visibility: visible;">
                  <p><b>
                  	库存：
        			</b></p>
                </div>&nbsp;&nbsp;
			      	${item.stock}
			      	</td>
			   </tr>
			   <c:forEach items="${item.itemSkuDOList}" var="itemskuDOTemp" varStatus="status">
			    <c:forEach items="${itemskuDOTemp.propertyValueDOList}" var="propertyValueDOTemp" varStatus="status">
			   <tr>
			      	<td>
                  	尺码：${propertyValueDOTemp.value}&nbsp;&nbsp;
			      	&nbsp;库存：${itemskuDOTemp.stock}
			      	</td>
			   </tr>
			   </c:forEach>
			   </c:forEach>
			    <tr>
					<td class="tc"><input class="btn_add" name="" value="保存修改" type="button" onclick="editItemDetailSubmit();" /></td>
				</tr>
		    </table>
	    </form>
  </div>
	<script type="text/javascript">
	    itemListParam = {'itemDesc' : '${itemDescBack}', 'itemCode' : '${itemCodeBack}', 'memberName' : '${memberNameBack}', 'pageNO' : '${itemListPageNum}'};
	    $(function(){
	    	var selectedFeatureText = $("#featureSelect").find("option:selected").text();
	    	var tagList = $("button.tagListButton");
	    	$.each(tagList,function (index,tagEle) {
	    		if ($(tagEle).text().replace(/(^\s*)|(\s*$)/g, "") == selectedFeatureText.replace(/(^\s*)|(\s*$)/g, "")) {
	    			$(tagEle).parent().addClass("featureTag");
	    		}
	    	});
	    }); 
    </script>